//prototypes begin
window.error = function () {}
window.log = console && console.log;
(function () {
  var s = a.string();
  for (var k in s)
    if (typeof s[k] == 'function') String.prototype[k] = s[k];
  var d = a.date();
  for (k in d)
    if (typeof d[k] == 'function') Date.prototype[k] = d[k];
  if (!Array.prototype.forEach) {
    Array.prototype.forEach = function (fun) {
      for (var i = 0; i < this.length; i++) fun.call(this, this[i], i, this);
    }
  }
})()
//prototypes end
//creatElement begin
a.creatElement = function (tagName, args) {
  args = args || {};
  var o = args.svg ? document.createElementNS('http://www.w3.org/2000/svg',tagName) : document.createElement(tagName);
  for (var key in args)
    if (key != 'parent' && key != 'attr' && key != 'style') o[key] = args[key];
  if (args.attr)
    for (key in args.attr) o.setAttribute(key, args.attr[key]);
  if (args.style) {
    if (typeof args.style == 'string') args.style = a.styleSheet(args.style);
    for (key in args.style) o.style[key] = args.style[key];
  }
  if (args.parent) {
    if (args.parent.appendChild) {
      args.parent.appendChild(o);
    } else {
      document.body.appendChild(o);
    }
  }
  return o;
}
//creatElement end
//computPX begin
//px单位按照分辨率等比转换
a.body = document.body;
a.computPX = function (n) {
  return n == 1 ? 1 : n * (a.Storage.state.pxScale || a.body.clientWidth / 750);
}
//computPX end
//computStyle begin
a.computStyle = function (styleString, args) {
  styleString = styleString.replace(new RegExp('([0-9]+)px', 'gm'), function ($0, $1) {
    return a.computPX($1) + 'px';
  }).replace(new RegExp('([0-9]+)rpx', 'gm'), function ($0, $1) {
    return a.computPX($1) + 'rpx';
  })
  if (args)
    for (var key in args) styleString = styleString.replace(new RegExp('{' + key + '}', 'g'), args[key]);
  return styleString;
}
//computStyle end
//computCSS begin
a.computCSS = function (url, next, args) {
  args = args || {};
  var id = args.id || 'setStyle' + a.zIndex();
  args.dataType = 'text';
  args.noLoginAction = true;
  args.noBeforeLoginAction = true;
  var styleElem = document.getElementById(id);
  if (!styleElem) {
    styleElem = a.creatElement('style', {
      id: id,
      type: 'text/css',
      parent: args.parent || true
    })
    styleElem.css = document.styleSheets[document.styleSheets.length - 1];
  }

  function parseCSS(ret) {
    ret = a.computStyle(typeof ret == 'string' ? ret : '');
    if (args.replace) ret = args.replace(ret);
    if (!styleElem.css.cssRules) {
      var rules = ret.split('}');
      for (var i = rules.length - 2; i >= 0; i--) {
        rules[i] = rules[i].split('{');
        try {
          styleElem.css.addRule(rules[i][0], rules[i][1]);
        } catch (e) {}
      }
    } else if (styleElem.css.cssRules) {
      styleElem.innerHTML += '\r' + ret;
    }
    if (next) next();
  }
  if (/\.css/.test(url)) {
    var ajax = new a.Ajax(url, function (ret) {
      parseCSS(ret);
    }, args)
    ajax.action();
  } else {
    parseCSS(url);
  }
}
//computCSS end
//styleSheet begin
a.styleSheet = function (styles, o) {
  var rc = {};
  styles = a.string(styles)._eval(o || {}).replace(/rpx/g, 'px');
  styles = styles.split(';');
  for (var i = 0; i < styles.length; i++) {
    if (!styles[i] || styles[i].indexOf(':') == -1) continue;
    var style = styles[i].split(':');
    var name = style[0].replace(/\s/g, '').replace(/-([a-z])/g, function ($0, $1) {
      return $1.toUpperCase();
    })
    rc[name] = style[1];
  }
  return rc;
}
//styleSheet end
//detectZoom begin
//获取浏览器缩放比例
a.detectZoom = function () {
  var ratio = 0;
  if (window.devicePixelRatio) {
    ratio = window.devicePixelRatio;
  } else if (window.screen && window.screen.deviceXDPI && window.screen.logicalXDPI) {
    ratio = window.screen.deviceXDPI / window.screen.logicalXDPI;
  } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
    ratio = window.outerWidth / window.innerWidth;
  }
  return Math.round(ratio * 100);
}
//detectZoom end
//getParam begin
//window获取参数
a.getParam = function (name) {
  var r = window.location.href.split('?');
  if(!r[1]) return null;
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  r = r[1].match(reg);
  if (r != null) return decodeURIComponent(r[2]);
  return null;
}
//getParam end
//Cookie begin
a.Cookie = {
  useH5: true,
  Get: function (name) {
    if (localStorage && this.useH5) {
      return localStorage[name];
    }
    var start = document.cookie.indexOf(name + '=');
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length)))
      return null;
    if (start == -1)
      return null;
    var end = document.cookie.indexOf(';', len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
  },
  Set: function (name, value, expires, path, domain, secure) { //设置cookie Set("flight_search", log, 7, "/");
    if (localStorage && this.useH5) {
      localStorage[name] = value;
      return false;
    }
    var today = new Date();
    today.setTime(today.getTime());
    if (expires) {
      expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));
    document.cookie = name + "=" + escape(value) +
      ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
      ((path) ? ";path=" + path : "") +
      ((domain) ? ";domain=" + domain : "") +
      ((secure) ? ";secure" : "");
  },
  Delete: function (name, path, domain) {
    if (localStorage && this.useH5) {
      localStorage[name] = '';
      return false;
    }
    if (this.Get(name)) {
      document.cookie =
        name + '=' +
        ((path) ? ';path=' + path : '') +
        ((domain) ? ';domain=' + domain : '') +
        ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
    }
  }
}
//Cookie end
//BlobFileToURL begin 临时URL对象 非base64
a.BlobFileToURL = (window.URL && URL.createObjectURL.bind(URL)) || (window.webkitURL && webkitURL.createObjectURL.bind(webkitURL)) || window.createObjectURL;
//BlobFileToURL end
//RevokeBlobFileToURL begin
a.RevokeBlobFileToURL = (window.URL && URL.revokeObjectURL.bind(URL)) || (window.webkitURL && webkitURL.revokeObjectURL.bind(webkitURL)) || window.revokeObjectURL;
//RevokeBlobFileToURL end
//UrlToBlob begin base64 url转blob
a.UrlToBlob = function (dataurl) {
  var arr = dataurl.split(','),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);
  while (n--) {
    u8arr[n] = bstr.charCodeAt(n);
  }
  return new Blob([u8arr], {
    type: mime
  });
}
//UrlToBlob end
//FileBlobToUrl begin file以及blob转base64 url
a.FileBlobToUrl = function (file, callback) {
  var f = new FileReader();
  f.onload = function (e) {
    callback(e.target.result);
  }
  f.readAsDataURL(file);
}
//FileBlobToUrl end
//useStrict begin
//判断浏览器是否支持js严格模式 IE10及以上
a.useStrict = (function () {
  "use strict";
  try {
    useStrict = undefined;
  } catch (e) {
    return true;
  }
})()
//useStrict end
//isIE7 begin
//利用ie7 css的*属性 检测是否ie7
a.isIE7 = (function () {
  var body = document.getElementsByTagName('body')[0];
  var hick = document.createElement('div');
  hick.setAttribute('style', 'position:absolute;left:100px;*left:1px;width:1px;');
  body.appendChild(hick);
  var rect = hick.getBoundingClientRect();
  body.removeChild(hick);
  return rect.left < 90;
})()
//isIE7 end
//platform begin
a.platform = (function () {
  if (a.body.clientWidth > 750) return 'Web'
  var agent = navigator.userAgent.toLowerCase();
  if (/iphone|ipad/.test(agent)) {
    return 'iOS';
  } else if (/android/.test(agent)) {
    return 'Android';
  } else {
    return 'Web';
  }
})()
//platform end
//on begin
a.on = function (elem, type, callback, args) {
  args = args || {};
  var xy = args.xy,
    z = args.z,
    hasType = true,
    _event;
  switch (type) { //滑动动作
    case 'pan':
      xy = [70, 1000];
      break;
    case 'move':
      xy = [0, 10000];
      break;
    case 'longpress':
      xy = [0, 50];
      z = 500;
      break;
    default:
      hasType = false;
      if (elem.addEventListener) {
        elem.addEventListener(type, function (event) {
          event = event || window.event;
          callback.call(this, event);
        }, typeof args == 'boolean');
      } else if (elem.attachEvent) {
        elem.attachEvent('on' + type, function (event) {
          event = event || window.event;
          callback.call(this, event);
        });
      }
      break;
  }
  if (!hasType) return false;
  var moveing = false,
    touchStartX, touchStartY, touchStartZ, move;
  var touchname = ('ontouchstart' in document.documentElement || 'ontouchstart' in document) && navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad|SymbianOS|Windows Phone)/i) ? ['touchstart', 'touchmove', 'touchend', 'touchleave'] : ['mousedown', 'mousemove', 'mouseup', 'mouseout'];
  a.on(elem, touchname[0], _start);
  a.on(elem, touchname[1], function (event) {
    _event = event;
    if (type == 'move' && moveing) _end(event, true);
  });
  a.on(elem, touchname[2], _end);
  a.on(elem, touchname[3], _end);
  var timer = 0;

  function _start(e) {
    e = e || window.event;
    _event = e;
    moveing = true;
    if (args.start) move = args.start(e);
    touchStartX = e.changedTouches ? e.changedTouches[0].clientX : e.clientX;
    touchStartY = e.changedTouches ? e.changedTouches[0].clientY : e.clientY;
    touchStartZ = new Date();
    if (type == 'longpress' && z) {
      timer = setTimeout(function () {
        if (timer) {
          timer = 0;
          _end(_event, true);
        }
      }, z)
    }
  }

  function _end(e, ismoveing) {
    e = e || window.event;
    _event = e;
    if (!ismoveing) {
      moveing = false;
      if (typeof args.end == 'function') args.end(e);
    }
    if (type == 'longpress' && timer) {
      clearTimeout(timer);
      timer = 0;
      moveing = false;
    }
    if (!moveing) return false;
    var xyz = {
      x: 0,
      y: 0,
      z: 0,
      type: type
    };
    var _touchStartX = e.changedTouches ? e.changedTouches[0].clientX : e.clientX;
    _touchStartX = _touchStartX - touchStartX;
    xyz.x = _touchStartX;
    _touchStartX = Math.abs(_touchStartX);
    var _touchStartY = e.changedTouches ? e.changedTouches[0].clientY : e.clientY;
    _touchStartY = _touchStartY - touchStartY;
    xyz.y = _touchStartY;
    _touchStartY = Math.abs(_touchStartY);
    var _touchStartZ = new Date();
    xyz.z = _touchStartZ - touchStartZ;
    _touchStartZ = Math.abs(_touchStartZ);
    if (move && move.length) {
      xyz._x = move[0] + xyz.x;
      xyz._y = move[1] + xyz.y;
      if (move[2]) xyz._z = move[2] + xyz.z;
    }
    var _xy = Math.sqrt(_touchStartX * _touchStartX + _touchStartY * _touchStartY);
    if (xy && (_xy < xy[0] || _xy > xy[1])) return false;
    if (z && (_touchStartZ < z[0] || _touchStartZ > z[1])) return false;
    e.xyz = xyz;
    callback(e);
  }
  return [_start, _end];
}
//on end
//getBoundingClientRect begin
a.getBoundingClientRect = function (dom) {
  var rect = dom.getBoundingClientRect();
  return {
    element:dom,
    trueWidth: rect.width,
    top: rect.top - document.documentElement.clientTop,
    bottom: rect.bottom,
    left: rect.left - document.documentElement.clientLeft,
    right: rect.right,
    width: rect.width || dom.offsetWidth,
    height: rect.height || dom.offsetHeight
  }
}
//getBoundingClientRect end
//Upload begin
a.Upload = function (args) {
  args = args || {};
  var _this = this;
  this.id = args.id;
  this.url = args.url;
  this.callback = args.callback || new Function();
  this.limit = args.limit ? args.limit : 1;
  this.maxSize = args.maxSize != undefined ? args.maxSize : (10 * 1024 * 1024);
  this.header = args.header ? args.header : [];
  this.fileKey = args.fileKey || 'file';
  this.accept = args.accept || '*';
  this.ImgEdit = args.ImgEdit == false ? '' : new a.ImgEdit(args);
  this.urlFormat = args.urlFormat;
  this.uploadFile = args.uploadFile;
  this.upIndex = args.upIndex;
  this.init = function (args) {
    args = args || {};
    a.merge(this, args);
    if (this.ImgEdit) this.ImgEdit.init(args);
    this.uploaded.splice(0, this.uploaded.length);
  }
  this.click = function () {
    var attr = {
      accept: this.accept
    };
    if (this.limit > 1 && this.upIndex == undefined) attr.multiple = 'multiple';
    var input = a.creatElement('input', {
      type: 'file',
      attr: attr,
      onchange: function () {
        _this.uploads(this.files, 'file');
      }
    })
    input.click();
  }
  this.uploaded = [];
  this.remove = function (i) {
    this.uploaded.splice(i, 1);
    this.callback(this.uploaded);
  }
  this.uploads = function (files, type) {
    var fileItems = new a.Item(),
      errs = [];
    for (var i = 0; i < files.length; i++) {
      (function (i) {
        fileItems._push(function (next) {
          function _next(ret) {
            if (!ret.errorMsg) {
              ret = _this.urlFormat ? _this.urlFormat.call(_this,ret) : ret;
              if(_this.upIndex >= 0){
                _this.uploaded[-(-_this.upIndex)] = ret;
                _this.upIndex = undefined;
              }else{
                _this.uploaded.push(ret);
              }
            } else {
              errs.push(ret.errorMsg)
            }
            next();
          }
          if (type == 'file') {
            a.FileBlobToUrl(files[i], function (url) {
              _this.upload({
                url: url,
                blob: a.UrlToBlob(url),
                name: files[i].name
              }, _next);
            })
          } else if (type == 'blob') {
            a.FileBlobToUrl(files[i].blob, function (url) {
              files[i].url = url;
              _this.upload(files[i], _next);
            })
          } else if (type == 'base64') {
            files[i].blob = a.UrlToBlob(files[i].url);
            _this.upload(files[i], _next);
          } else {
            _this.upload(files[i], _next);
          }
        })
      })(i)
    }
    fileItems._push(function () {
      _this.callback(_this.uploaded, errs.join(','));
    });
    fileItems._do();
  }
  this.beforeAction = args.beforeAction;
  this.upload = function (fileObject, next) {
    if (this.uploaded.length >= this.limit) {
      next({
        errorMsg: '已超过上传数量限制,' + fileObject.name + '无须上传'
      });
      return false;
    }
    if (this.ImgEdit && /image/.test(fileObject.blob.type)) {
      this.ImgEdit.open(fileObject.url, _do, {
        name: fileObject.name
      });
    } else {
      _do(fileObject);
    }

    function _do(fileObject) {
      if (fileObject.errorMsg) {
        next(fileObject);
        return false;
      }
      // if (fileObject.blob.size > _this.maxSize) {
      //   next({
      //     errorMsg: fileObject.name + '文件超过大小限制'
      //   });
      //   return false;
      // }
      if (_this.accept != '*' && !new RegExp(_this.accept).test(fileObject.blob.type)) {
        next({
          errorMsg: fileObject.name + '文件类型不符'
        });
        return false;
      }
      var ajaxConfig = a.clone(args.ajax || {});
      ajaxConfig.data = new FormData();
      fileObject.name = fileObject.name || (new Date().getTime() + '.' + fileObject.blob.type);
      if (typeof _this.beforeAction == 'function') {
        _this.beforeAction.call(_this, function () {
          uploadFile()
        }, fileObject, ajaxConfig)
      } else {
        uploadFile()
      }

      function uploadFile() {
        if(_this.uploadFile){
          _this.uploadFile.call(_this,fileObject, ajaxConfig,next);
        }else{
          ajaxConfig.meth = ajaxConfig.meth || 'POST';
          if (ajaxConfig.data && ajaxConfig.data.constructor && ajaxConfig.data.constructor.toString().indexOf('function FormData()') == 0) {
            ajaxConfig.data.append(_this.fileKey, fileObject.blob, fileObject.name);
            if (ajaxConfig.formData)
              for (var key in ajaxConfig.formData) ajaxConfig.data.append(key, ajaxConfig.formData[key]);
          }
          new a.Ajax(ajaxConfig.url || _this.url, next, ajaxConfig).action();
        }
      }
    }
  }
}
//Upload end
//showFile begin
a.showFile = function (url) {
  window.open(url, '_blank');
}
//下载文件
a.downFile = async function(url){
  try {
    const response = await fetch(url);
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
    let urls = url.split('/')
    const blob = await response.blob()
    const _url = window.URL.createObjectURL(blob)
    const a = document.createElement('a')
    a.href = _url
    a.download = urls[urls.length - 1]
    a.click()
    window.URL.revokeObjectURL(_url)
  } catch (error) {
      console.error('下载文件时出错:', error)
  }
}
//数据准备页面
a.PageLoading = {
  count:0,
  dom:null,
  innerHTML:'',
  style:{
    position:'fixed',
    left:'0',
    top:'0',
    right:'0',
    bottom:'0',
    zIndex:a.zIndex(4),
    background:'#fff',
    color:'#ccc',
    fontSize:'18px',
    display:'flex',
    justifyContent:'center',
    alignItems:'center'
  },
  firstOpenTime:0,
  maxtime:10,//10秒后不再准备
  loadingMaxTime:2 * 60,//默认1分钟最大准备时间
  timer:0,
  open(innerHTML){
    let nowTime = new Date().getTime()
    //页面准备完成后就不需要启动loading了
    if(this.firstOpenTime && nowTime - this.firstOpenTime > this.maxtime * 1000){
      return
    }
    this.count ++
    if(this.count == 1){
      this.dom = a.creatElement('div',{
        innerHTML:innerHTML || this.innerHTML,
        style:this.style
      })
      a.body.appendChild(this.dom)
      this.firstOpenTime = nowTime
      this.timer = setTimeout(()=>{//最大加载时间后移出
        a.body.removeChild(this.dom)
        this.dom = null
        this.timer = 0
        if(confirm('长时间未响应，刷新页面试试？')) location.reload()
      },this.loadingMaxTime * 1000)
    }
  },
  close(){
    this.count --
    if(this.count <= 0 && this.dom) {
      a.body.removeChild(this.dom)
      this.dom = null
      this.count = 0
      if(this.timer){
        clearTimeout(this.timer)
        this.timer = 0
      }
    }
  }
}
//showFile end
//RichEditor begin
a.RichEditor = function (element,args) {
  var _this = this;
  args = args || {};
  args.width = args.width || 375;
  this.name = args.name || a.guid();

  var APIURL = a.Storage.get('APIURL');
  this.uploadConfig = {
    url: APIURL + '/upload',
    urlFormat: function (ret) {
      ret.url = APIURL + '/file/' + ret.id
      return ret;
    }
  }
  var mixinputUpload = a.Storage.get('mixinputUpload');
  if(typeof mixinputUpload == 'function'){
    mixinputUpload.call(this,this.uploadConfig);
  }else if(mixinputUpload && typeof mixinputUpload == 'object'){
    a.merge(this.uploadConfig, mixinputUpload);
  }
  a.merge(this.uploadConfig, args.uploadConfig || {});
  this.restoreRange = function(){
    document.getSelection().removeAllRanges();      //把没用的Ranges删除
    document.getSelection().addRange(this.range); 
    // var _selection = document.createRange();
    // _selection.setStart(this.range.startContainer,this.range.startOffset);
    // _selection.setEnd(this.range.endContainer,this.range.endOffset);
    // _selection.collapse(this.range.collapsed);
  }
  this.tools = [
    {
      tagName:'button',
      innerHTML:'插入图片',
      className:'editorButton',
      onclick:()=>{
        new a.Upload({
          ...this.uploadConfig,
          callback:(ret, errs) =>{
            if(ret.length && this.range) {
              this.restoreRange();
              document.execCommand('insertImage',false,ret[0].url);
              this.change();
            }
          }
        }).click();
      }
    },
    {
      tagName:'button',
      innerHTML:'字号',
      className:'editorButton',
      onclick:(e)=>{
        new a.Picker().pick({
          items:[
            {value:1,name:'一号'},
            {value:2,name:'二号'},
            {value:3,name:'三号'},
            {value:4,name:'四号'},
            {value:5,name:'五号'},
            {value:6,name:'六号'},
            {value:7,name:'七号'}
          ],
          pickBox:a.string('left:{pageX}px;top:{pageY}px;')._eval(e)
        },ret => {
          if(ret.length && this.range) {
            this.restoreRange();
            document.execCommand('fontSize', false,ret.data.value);
            this.change();
          }
        })
      }
    },
    // {
    //   tagName:'button',
    //   innerHTML:'颜色',
    //   className:'editorButton',
    //   onclick:(e)=>{
    //     new a.Picker().pickColor({
    //       pickBox:a.string('left:{pageX}px;top:{pageY}px;')._eval(e)
    //     },ret => {
    //       if(ret.data && this.range) {
    //         this.restoreRange();
    //         if(ret.data.value) document.execCommand('foreColor', false,ret.data.value);
    //         this.change();
    //       }
    //     })
    //   }
    // },
    {
      tagName:'button',
      innerHTML:'背景色',
      className:'editorButton',
      onclick:(e)=>{
        if(!this.range) return false;
        new a.Picker().pickColor({
          pickBox:a.string('left:{pageX}px;top:{pageY}px;')._eval(e)
        },ret => {
          if(ret.data && this.range) {
            this.restoreRange();
            document.execCommand('backColor', false,ret.data.value);
            this.change();
          }
        })
      }
    },
    {
      tagName:'button',
      innerHTML:'加粗',
      className:'editorButton',
      onclick:(e)=>{
        document.execCommand('bold', false);
        this.change();
      }
    }
  ]
  this.toolBar = null
  this.buildToolBar = function(event){
    var toolBar = a.creatElement('div',{
      style:{
        background:'#fff',
        border:'1px solid #e4e4e4',
        borderBottom:'none'
      },
      parent:element
    })
    for(var i = 0; i < this.tools.length; i ++){
      a.creatElement(this.tools[i].tagName,{
        ...this.tools[i],
        parent:toolBar
      })
    }
  }
  this.selection = null;
  this.range = null;
  this.container = null;
  this.init = function(){
    element.style.width = args.width + 'px';
    //element.style.border = '1px solid #e4e4e4';
    this.buildToolBar();
    this.container = a.creatElement('div',{
      parent:element,
      attr:{
        contenteditable:!args.disabled
      },
      style:{
        height:args.height ? args.height + 'px' : '100%',
        overflow:'auto',
        minHeight:'200px',
        border:'1px solid #e4e4e4'
      },
      className:'editor',
      onblur:event => {
        this.change(event);
      },
      onmouseup:event => {
        this.selection = window.getSelection();
        this.range = this.selection.getRangeAt(0);
        if(this.selection && !args.disabled){
          return false;
        }
        this.change(event);
      },
      onkeyup:event => {
        this.change(event);
      },
      onkeypress:event => {
        this.change(event);
      },
      onpaste:event => {
        this.change(event);
      }
    });
    a.creatElement('style',{
      innerHTML:'.editor img{max-width:90%;margin:16px;}.editorButton{margin:4px;border: 1px solid #e4e4e4;background: #e4e4e4;cursor: pointer;}',
      parent:element
    })
    if(args.value) this.container.innerHTML = args.value;
  }
  this.change = function(event){
    if(args.bindinput && this.value != this.container.innerHTML) {
      this.value = this.container.innerHTML;
      args.bindinput({
        event,
        detail:{
          html:this.value
        }
      })
    }
  }
  this.value = '';
  this.setContents = function(data){
    var html = data.delta || data.html;
    if(this.container.innerHTML != html){
      this.container.innerHTML = html;
      this.value = html;
    }
  }
  this.init();
}
//RichEditor end